﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using JQueryandMVC.library.Routing;

namespace JQueryandMVC
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute("SimpleModel",
                "SimpleModel",
                new { controller = "JQuerySample", action = "SimpleModel" }, null, null);

            routes.MapRoute("MonthCalendar",
                "MonthCalendar",
                new { controller = "Calendar", action = "MonthCalendar" }, null, null);

            //CalendarInfo
            routes.MapRoute("CalendarMonthInfo",
                "Calendar/MonthInfo/{year}/{month}",
                new { controller = "Calendar", action = "MonthEvents" },
                new
                {
                    year = new IsInt(DateTime.MinValue.Year, DateTime.MaxValue.Year),
                    month = new IsInt(DateTime.MinValue.Month, DateTime.MaxValue.Month)
                },                
                 null);

            routes.MapRoute("WeekCalendar",
                "WeekCalendar",

                new { controller = "Calendar", action = "WeekCalendar" }, null, null);

            //WeekEvents
            //CalendarInfo
            routes.MapRoute("CalendarWeekInfo",
                "Calendar/WeekInfo/{year}/{month}/{day}",
                new { controller = "Calendar", action = "WeekEvents" },
                new
                {
                    year = new IsInt(DateTime.MinValue.Year, DateTime.MaxValue.Year),
                    month = new IsInt(DateTime.MinValue.Month, DateTime.MaxValue.Month),
                    day = new IsInt(1,31)
                },
                 null);            
            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );


        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
        }
    }
}